<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var countTexts = function (pressedKeys) {
      const three = [1, 1, 2, 4];
      const four = [1, 1, 2, 4];
      const MOD = 1e9 + 7;
      const n = pressedKeys.length;
      let ans = 1n;

      for (let i = 4; i <= 1e5; i++) {
        three[i] = (three[i - 1] + three[i - 2] + three[i - 3]) % MOD;
        four[i] = (four[i - 1] + four[i - 2] + four[i - 3] + four[i - 4]) % MOD;
      }

      let count = 1;
      let curr = pressedKeys[0];

      for (let i = 1; i <= n; i++) {
        const key = pressedKeys[i];
        if (key === curr) {
          count++;
        } else {
          if (curr === '7' || curr === '9') {
            ans = ans * BigInt(four[count]) % BigInt(MOD);
          } else {
            ans = ans * BigInt(three[count]) % BigInt(MOD);
          }

          count = 1;
          curr = key;
        }
      }

      return ans;
    };
    console.log(countTexts("22233"));
  </script>
</body>

</html>